{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ee640277",
   "metadata": {},
   "source": [
    "### 方式1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "33bca3ea",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# 因为__init__.py文件中包含from lwtest.building_test import *，所以可以直接从lwtest文件夹中import lwtest.package中的方法\n",
    "from lwpackage.lwtest import print_time, check_init"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "290e29e7",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello, the time now is 2023-10-31 14:45:30.276441.\n"
     ]
    }
   ],
   "source": [
    "print_time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "44e66b5f",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Successfully build a new package.\n"
     ]
    }
   ],
   "source": [
    "check_init()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2766b99e",
   "metadata": {},
   "source": [
    "### 方式2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "389e2797",
   "metadata": {},
   "outputs": [],
   "source": [
    "from lwpackage import lwtest"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6454a095",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello, the time now is 2023-10-31 14:45:30.805025.\n"
     ]
    }
   ],
   "source": [
    "lwtest.print_time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "5add1fdf",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Successfully build a new package.\n"
     ]
    }
   ],
   "source": [
    "lwtest.check_init()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c9688b73",
   "metadata": {},
   "source": [
    "### 方式3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "c1da3393",
   "metadata": {},
   "outputs": [],
   "source": [
    "from lwpackage.lwtest import building_test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "737c81bf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello, the time now is 2023-10-31 14:45:31.267173.\n"
     ]
    }
   ],
   "source": [
    "building_test.print_time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "5888b013",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Successfully build a new package.\n"
     ]
    }
   ],
   "source": [
    "building_test.check_init()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb37ee9c",
   "metadata": {},
   "source": [
    "### 方式4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "b3ee86a3",
   "metadata": {},
   "outputs": [],
   "source": [
    "from lwpackage.lwtest.building_test import print_time, check_init"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "ec41f8d0",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello, the time now is 2023-10-31 14:45:32.864669.\n"
     ]
    }
   ],
   "source": [
    "print_time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "f269e28c",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Successfully build a new package.\n"
     ]
    }
   ],
   "source": [
    "check_init()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3bc146a4",
   "metadata": {},
   "source": [
    "### 测试__init__.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "763fb2e5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1785c8e3",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# 在外部使用from lwpackage import *的时候，只会运行lwpackage/__init__.py，而不会运行lwpackage/lwtest/__init__.py\n",
    "from lwpackage import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "49edb901",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# 在外部使用from lwpackage import *的时候，只会运行lwpackage/__init__.py，而不会运行lwpackage/lwtest/__init__.py\n",
    "from lwpackage import lwtest"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ba513d1b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1ab680e1",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "aloha\n",
      "halo\n"
     ]
    }
   ],
   "source": [
    "# 在外部使用from lwpackage import *的时候，只会运行lwpackage/__init__.py，而不会运行lwpackage/lwtest/__init__.py\n",
    "from lwpackage import lwtest"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4ee3f106",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "aloha\n",
      "halo\n"
     ]
    }
   ],
   "source": [
    "from lwpackage.lwtest import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "30879c7a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello, the time now is 2023-10-31 15:43:09.547066.\n"
     ]
    }
   ],
   "source": [
    "print_time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "49d7ebc2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3a57e925",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ca528839",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "311edb52",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:leoweng4.0] *",
   "language": "python",
   "name": "conda-env-leoweng4.0-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
